#include <iostream>
#include <string>
#include <jsoncpp/json/json.h>

int main()
{
    std::string json_string = "{\"name\":\"张三\", \"age\":30, \"city\":\"北京\"}";

    Json::Value root;
    Json::Reader reader;
    
    bool ok = reader.parse(json_string, root);
    (void)ok;

    std::string name = root["name"].asString();
    int age = root["age"].asInt();
    std::string city = root["city"].asString();

    Json::StyledWriter writer;
    std::string s = writer.write(root);
    std::cout << s << std::endl;

    // std::cout << name << std::endl;
    // std::cout << age << std::endl;
    // std::cout << city << std::endl;

    // Json::Value root;
    // root["name"] = "张三";
    // root["sex"] = "男";
    // root["age"] = 18;


    // Json::Value sub;
    // sub["name"] = "李四";
    // sub["sex"] = "男";
    // root["info"] = sub;

    // Json::StyledWriter writer;
    // std::string s = writer.write(root);
    // std::cout << s << std::endl;
}